//
//  BanBu_LabelViewController.m
//  BanBu
//
//  Created by Wang Xj on 13-12-24.
//
//

#import "BanBu_LabelViewController.h"

@interface BanBu_LabelViewController ()

@end

@implementation BanBu_LabelViewController

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}
-(void)viewWillAppear:(BOOL)animated
{
    [UIView setAnimationsEnabled:YES];
    [super viewWillAppear:animated];
}
-(void)dealloc
{
    [_folderName release],_folderName = nil;
    [_labelArray release],_labelArray = nil;
    
    [super dealloc];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    NSString * fileName = [[[NSHomeDirectory() stringByAppendingPathComponent:@"Library"] stringByAppendingPathComponent:@"Caches"] stringByAppendingPathComponent:@"watermark"];
    
    NSString * labelFile = [[fileName stringByAppendingPathComponent:self.folderName] stringByAppendingPathComponent:@"watermark-text.plist"];
    
    NSDictionary * labelDic = [NSDictionary dictionaryWithContentsOfFile:labelFile];
    
//    NSLog(@"labelFile:%@,labelDic:%@",labelFile,labelDic);
    self.labelArray = [NSMutableArray arrayWithArray:labelDic.allValues];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.labelArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    cell.textLabel.text = [self.labelArray objectAtIndex:indexPath.row];
    
    return cell;
}

#pragma mark - Table view delegate
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if ([self.delegate respondsToSelector:@selector(didSelectedRowIn:atIndexPath:)])
    {
        [self.delegate didSelectedRowIn:self atIndexPath:indexPath];
    }
}
@end
